<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对象</title>
</head>
<body>
<script>
    //声明一个空对象
    const obj = {};
    //给空对象添加属性和属性值
    obj.size = 10;
    obj.color = "yellow";
    //两种访问属性的方式
    console.log(obj['size']);
    console.log(obj.color);

    const person = {
        name:'sam',
        age:4
    };
    console.log("姓名：" + person.name + ",年龄：" + person.age);

    const person2 = {
        name:'sam',
        classificaion:{
            kingdown:'Anamalia',
            phylum:'Chordata',
            species:'catus'
        }
    };
    console.log("姓名：" + person2.name + ",王国：" + person2.classificaion.kingdown);

    const person3 = {
        name:'sam',
        Classificaion:{
            kingdown:'Anamalia',
            phylum:'Chordata',
            species:'catus'
        }
    };
    person3.speak = function(){
        console.log("姓名：" + person2.name + ",王国：" + person2.classificaion.phylum);
    }
    person3.speak();

    const person4 = {
        name:'sam',
        Classificaion:{
            kingdown:'Anamalia',
            phylum:'Chordata',
            species:'catus'
        },
        speak : function(){
            console.log("姓名：" + person2.name + ",王国：" + person2.classificaion.species);
        }
    };
    person4.speak();

</script>
</body>
</html>